home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / IEditor / ARexx / CenterText.ie < prev    next >
Text File  |  1997-06-17  |  753b  |  60 lines

  1. /*
  2.     CenterText
  3.     Center an IntuiText in a Bevel Box
  4. */
  5.  
  6. OPTIONS RESULTS
  7.  
  8. SIGNAL ON ERROR
  9.  
  10. ADDRESS 'IEDITOR.1'
  11.  
  12.  
  13. /* Ask the user to select a text... */
  14.  
  15. 'GETITEXT'
  16. txtn = result
  17.  
  18. /* ...and a box */
  19.  
  20. 'GETBOX'
  21. bevel = result
  22.  
  23.  
  24.  
  25. /*  Get the data we need  */
  26.  
  27. 'GETITEXTATTR' txtn txt
  28.  
  29. 'GETITEXTLENGTH' txtn
  30. len = result
  31.  
  32. if txt.font >= 0  then
  33.        'GETFONTATTR' txt.font fnt
  34.    else
  35.        'GETSCRFONT' fnt
  36.  
  37. 'GETBOXATTR' bevel bx
  38.  
  39.  
  40. /*  Compute the new coordinates  */
  41.  
  42. newx = (bx.leftedge + TRUNC(( bx.width / 2),0)) - TRUNC((len / 2),0)
  43.  
  44. newy = bx.topedge - TRUNC((fnt.ysize / 2),0) + 1
  45.  
  46.  
  47. /*  Set RP_JAM2 and BackPen = 0  and center the text */
  48.  
  49. 'SETITEXTATTR' txtn 'BP 0 M 1 X' newx 'Y' newy
  50.  
  51.  
  52. EXIT
  53.  
  54.  
  55. ERROR:
  56.  
  57. say 'Error' RC 'on line' SIGL
  58.  
  59. EXIT RC
  60.